package com.wyx.rtddels.service.impl;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.wyx.rtddels.domain.RtdTag;
import com.wyx.rtddels.domain.delRepeat.DelRepeatDomain;
import com.wyx.rtddels.domain.dto.ExportDomain;
import com.wyx.rtddels.service.DelRepeatService;
import com.wyx.rtddels.service.RtdTagService;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.FileInputStream;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * @author WYX
 * @date 2024/12/13
 * @Description
 */
@Service
public class DelRepeatServiceImpl  implements DelRepeatService {

    @Autowired
    RtdTagService rtdTagService;


    // 最大数
    private AtomicInteger num=new AtomicInteger(10);
    /**
     * @deprecated  删除重复数据 只保留filePath csv文件中含有的
     * @param filePath
     */
    @SneakyThrows
    @Override
    public void delRepeat(String filePath) {
        // 全部属性值获取
        List<RtdTag> rtdTags = rtdTagService.list();
        //获取全部的id号

        FileInputStream fileInputStream = new FileInputStream(filePath);
        // 读取文件 的内容
        List<DelRepeatDomain> list = EasyExcel.read(fileInputStream).head(DelRepeatDomain.class).excelType(ExcelTypeEnum.CSV).sheet().doReadSync();
        //直接剩下现在不存在的点位值 直接删除即可

        //  rtdTags.remove(rtdTagService.getOnes(k.getTagName()).getId()
        list.stream().map(k ->{
          return   rtdTags.stream().map(z->{
                z.getTag().contains(k.getTagName());
                return z.getId();
            }).collect(Collectors.toList());


        });
        System.out.println(list);

        List<Integer> collect = IntStream.range(0, rtdTags.size()).mapToObj(i ->
                rtdTags.get(i).getId()).collect(Collectors.toList());
    }
}
